package com.wcw.encryptor;

import java.util.Properties;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.shardingsphere.encrypt.strategy.spi.Encryptor;

public class Sha256Encryptor implements Encryptor {

	private Properties properties = new Properties();

	@Override
	public void init() {

	}

	@Override
	public String encrypt(Object plaintext) {
		if (null == plaintext) {
			return null;
		}
		return DigestUtils.sha256Hex(String.valueOf(plaintext));
	}

	@Override
	public Object decrypt(String ciphertext) {
		return ciphertext;
	}
	// 加解密器的类型
	@Override
	public String getType() {
		return "SHA256";
	}

	@Override
	public Properties getProperties() {
		return properties;
	}

	@Override
	public void setProperties(Properties properties) {
		this.properties = properties;
	}
}
